<!--
 * @Description: 已登录状态头部组件
-->
<template>
  <div class="header-login">
    <div class="mode-tabs">
      <div 
        :class="['tab-item', { active: mode === 'schedule' }]"
        @click="handleModeClick('schedule')"
      >
        日程
        <el-badge v-if="mode === 'schedule'" :value="scheduleCount" class="tab-badge" />
      </div>
      <div 
        :class="['tab-item', { active: mode === 'menu' }]"
        @click="handleModeClick('menu')"
      >
        事项
        <el-badge v-if="mode === 'menu' && count > 0" :value="count" class="tab-badge" />
      </div>
    </div>
    
    <div class="calendar-section">
      <div class="date-list">
        <div 
          v-for="(item, index) in riliList" 
          :key="item.key"
          :class="['date-item', { active: item.checked }]"
          @click="handleDateClick(index, item)"
        >
          <div class="weekday">{{ item.weekday }}</div>
          <div class="date">{{ item.value }}</div>
        </div>
      </div>
      <el-button class="more-btn" @click="handleScheduleClick">更多</el-button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'

interface Props {
  mode: string
  riliList: any[]
  count: number
}

const props = defineProps<Props>()

const emit = defineEmits<{
  onMode: [string]
  onSchedule: []
  onCalendarDay: [{ index: number; time: string }]
}>()

const scheduleCount = computed(() => {
  // 这里可以计算日程数量
  return 0
})

const handleModeClick = (newMode: string) => {
  emit('onMode', newMode)
}

const handleDateClick = (index: number, item: any) => {
  emit('onCalendarDay', { index, time: item.key })
}

const handleScheduleClick = () => {
  emit('onSchedule')
}
</script>

<style scoped lang="less">
.header-login {
  background: #fff;
  border-radius: 12px;
  margin: 0 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.mode-tabs {
  display: flex;
  border-bottom: 1px solid #ebeef5;
  
  .tab-item {
    flex: 1;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    
    &.active {
      color: #409eff;
      background-color: #f0f9ff;
      
      &::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 2px;
        background-color: #409eff;
      }
    }
    
    &:hover:not(.active) {
      background-color: #f5f7fa;
    }
    
    .tab-badge {
      margin-left: 8px;
    }
  }
}

.calendar-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
}

.date-list {
  display: flex;
  gap: 8px;
  flex: 1;
}

.date-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  
  &.active {
    background-color: #409eff;
    color: #fff;
  }
  
  &:hover:not(.active) {
    background-color: #f5f7fa;
  }
  
  .weekday {
    font-size: 12px;
    margin-bottom: 4px;
  }
  
  .date {
    font-size: 14px;
    font-weight: 500;
  }
}

.more-btn {
  margin-left: 16px;
}
</style>
